package com.requiem.hist_group_manage_springboot.controller;

import com.requiem.hist_group_manage_springboot.exception.R;
import com.requiem.hist_group_manage_springboot.model.GroupModel;
import com.requiem.hist_group_manage_springboot.service.GroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping({"/group"})
public class GroupController {
    @Autowired
    GroupService groupService;

    @GetMapping({"/getList"})
    R getList() {
        return groupService.getList();
    }

    @GetMapping({"/get"})
    R getByID() {
        return groupService.getByID();
    }

    @GetMapping({"/getStudent"})
    R getStudent() {
        return groupService.getStudent();
    }

    @GetMapping({"/getTeacher"})
    R getTeacher() {
        return groupService.getTeacher();
    }

    @GetMapping("/getLog")
    R getLog() {
        return groupService.getLog();
    }

    @PostMapping({"/add"})
    R add(@RequestBody GroupModel groupModel) {
        return groupService.add(groupModel);
    }

    @DeleteMapping({"/delete"})
    R delete() {
        return groupService.delete();
    }

    @PostMapping({"/edit"})
    R edit(@RequestBody GroupModel groupModel) {
        return groupService.edit(groupModel);
    }

    @PostMapping("/Search")
    R getSearch(@RequestBody GroupModel groupModel) {
        return groupService.SearchList(groupModel);
    }
}
